const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');

module.exports = {
    entry: './src/app.js',
    output: {
        path: path.resolve(__dirname, 'dist'),
        filename: 'app.js',
    },
    plugins: [
        new HtmlWebpackPlugin({
            filename: 'index.html',
            template: 'src/index.html'
        })
    ],
    module: {
        rules: [{
            test: /\.js$/,
            use: [{
                loader: 'babel-loader',
                options: {
                    presets: ['react']
                }
            }]
        }]
    }
};

//npm init -y    //初始化项目，执行后会多一个package.json页面
//npm i -D webpack@3   //安装项目依赖，这里安装3.0版本的webpack

//npm i -D html-webpack-plugin      //安装html-webpack-plugin插件，用来打包时创建html页面
//---------------------------------------------------------------------------

//npm i
//npm i -S react react-dom
//npm i -D babel-loader babel-core
//npm i -D babel-preset-react